<template>
  <!--  br 标签给页脚留出位置  -->
  <br />
  <div id="footer">
    <el-divider></el-divider>
    <img :src="img1" />
    <p class="footer">
      Copyright © 2021 http://wzqblog.top |
      <a
        @click="toUrl('https://beian.miit.gov.cn/#/Integrated/index')"
        class="beian"
        >苏ICP备2020066710-2号</a>
    </p>
    <p id="htmer_time" style="color: black" class="footer"></p>
    <br />
  </div>
</template>

<script>
import img1 from "/images/1.gif";
export default {
  name: "Footer",
  mounted() {
    function secondToDate(second) {
      if (!second) {
        return 0;
      }
      var time = new Array(0, 0, 0, 0, 0);
      if (second >= 365 * 24 * 3600) {
        time[0] = parseInt(second / (365 * 24 * 3600));
        second %= 365 * 24 * 3600;
      }
      if (second >= 24 * 3600) {
        time[1] = parseInt(second / (24 * 3600));
        second %= 24 * 3600;
      }
      if (second >= 3600) {
        time[2] = parseInt(second / 3600);
        second %= 3600;
      }
      if (second >= 60) {
        time[3] = parseInt(second / 60);
        second %= 60;
      }
      if (second > 0) {
        time[4] = second;
      }
      return time;
    }
    function setTime() {
      //mouth要少一个月不然会出问题
      var create_time = Math.round(
        new Date(Date.UTC(2021, 2, 18, 0, 0, 0)).getTime() / 1000
      );
      var timestamp = Math.round(
        (new Date().getTime() + 8 * 60 * 60 * 1000) / 1000
      );
      var currentTime = secondToDate(timestamp - create_time);
      var currentTimeHtml =
        currentTime[0] +
        "年" +
        currentTime[1] +
        "天" +
        currentTime[2] +
        "时" +
        currentTime[3] +
        "分" +
        currentTime[4] +
        "秒";
      if (document.getElementById("htmer_time") != null)
        document.getElementById("htmer_time").innerHTML =
          "该网站已运行了" + currentTimeHtml;
    }
    //即时刷新
    setInterval(setTime, 1000);
  },
  methods: {
    toUrl(url) {
      //window.location.href=url;
      window.open(url, "_blank");
    },
  },
  data(){
    return{
      img1,
    };
  },
};
</script>

<style scoped>
#footer {
  /*position: fixed;*/
  left: 0;
  bottom: 0px;
  height: 50px;
  width: 100%;
  background: white;
  text-align: center;
  font-family: KaiTi;
}
.footer {
  color: gray;
}
.beian{
  cursor: pointer;
}
.beian:hover{
  color: lightskyblue;
}
</style>
